# Create your views here.
from django.http import HttpResponse
from django.shortcuts import render_to_response,redirect
from musicmovie.models import Movie
import simplejson

from myuser.usercheck import getUser

def index(request):
    """
    page to show the new added movie(at most ten)
    search the movie

    """
    dic = {}
    user = getUser(request)
    if user:
        dic['user'] = user
    doubannewlist = []
    movies = Movie.all().order("-addtime").fetch(5)
    for movie in movies:
        tmpdic = simplejson.loads(movie.jsondesp)
        doubannewlist.append(tmpdic)
    dic['movies'] = doubannewlist
    return render_to_response("musicmovie/musicmovieindex.html",dic)
    #return HttpResponse("hola")

def addMusic2Movie(request):
    """
    the page for inter action to add a music link to a movie
    """

def checkUserAdd(request):
    """
    admin only
    the page to show all user action
    administrator make approve or deny and send the user with an email
    """

def MoviePage(request):
    """
    page to show a movie and related music piece
    """

def LinkPage(request):
    """
    create a link page(using the flex project)
    to show the link info about music and movie
    """
